package com.dmall.netty.chapter02.section21.bio;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

public class TimeClient {

	public static void main(String[] args) {
		int port = 8080;
		if (args != null && args.length > 0) {
			try {
				port = Integer.valueOf(args[0]);
			} catch (Exception e) {
				// 默认值
			}
		}
		
		Socket socket = null;
		BufferedReader in = null;
		PrintWriter out = null;
		try {
			socket = new Socket("127.0.0.1", port);
			in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
			out = new PrintWriter(socket.getOutputStream(), true);
			String request = "QUERY TIME ORDER";
			out.println(request);
			System.out.println("Send order 2 server succeed.");
			String body = in.readLine();
			System.out.println("Now is " + body);
		} catch (Exception e) {
			
		} finally {
			
		}
	}
}
